import store from '@/common/store';

import {
	ElMessageBox
} from 'element-plus'

let isMessageAlert = false

function messageAlert() {
	if (isMessageAlert) return
	isMessageAlert = true
	ElMessageBox.alert('token失效，请重新登录。', '提示', {
		confirmButtonText: '确定',
		showClose: false,
		type: 'warning',
		callback: () => {
			store.commit('logout');

			uni.$emit('loginOut');

			uni.redirectTo({
				url: '/pages/login'
			})
		}
	})
}

export default messageAlert